package demo.mapper;

import demo.pojo.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BookMapper  {
    @Select("select * from book where  id = #{id}")
    Book findBookById(Integer id);
    @Select("select * from book where `del` = 0")
    List<Book> findAllBook();
    @Update("update book set name = #{name},press = #{press},author = #{author},updatetime =  #{updateTime},image = #{image} where id = #{id}")
    void updateBook(Book book);
    @Update("update book set `del` = 1 where id = #{id}")
    void deleteById(Integer id);
    @Select("select * from book where name like '%${name}%' or press like '%${name}%' or author like '%${name}%'")
    List<Book> searchLike(String name);

    void insert(Book book);
}
